<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="../../../component/pear/css/pear.css"/>
</head>
<body>
<form class="layui-form" action="">
    <div class="mainBox">
        <div class="main-container">
            <div class="main-container">
                <div class="layui-form-item">
                    <label class="layui-form-label">旧密码</label>
                    <div class="layui-input-block">
                        <input type="password" name="oldPassword" lay-verify="title|required" autocomplete="off"
                               placeholder="请输入标题" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">新密码</label>
                    <div class="layui-input-block">
                        <input type="password" name="newPassword" lay-verify="title|required" autocomplete="off"
                               placeholder="请输入标题" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">确认密码</label>
                    <div class="layui-input-block">
                        <input type="password" name="confirmPassword" lay-verify="title|required" autocomplete="off"
                               placeholder="请输入标题" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit=""
                                lay-filter="edit-password">
                            <i class="layui-icon layui-icon-ok"></i>
                            提交
                        </button>
                        <button type="reset" class="pear-btn pear-btn-sm">
                            <i class="layui-icon layui-icon-refresh"></i>
                            重置
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</form>
<script src="../../../component/layui/layui.js"></script>
<script src="../../../component/pear/pear.js"></script>
<script>
    layui.use(['form', 'jquery', 'popup', 'easyAdmin'], function () {
        let form = layui.form;
        let $ = layui.jquery;
        let popup = layui.popup;
        let easyAdmin = layui.easyAdmin;

        form.on('submit(edit-password)', function (data) {
            easyAdmin.http({
                url: '/sys/user/updatePwd',
                data: JSON.stringify(data.field),
                contentType: 'application/json',
                dataType: 'json',
                type: 'put',
                success: function (result) {
                    if (result.success) {
                        layer.msg("修改密码成功", {icon: 1, time: 2000, area: ['100px', '65px']});
                    } else {
                        layer.msg(result.msg, {icon: 2, time: 2000, area: ['260px', '65px']});
                    }
                }
            })
            return false;
        });

    })
</script>
</body>
</html>